package com.fay.designPattern.pattern.create.prototype;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * @Title:
 * @Description:
 * @Author Fay Wang
 * @Date 2022/4/14 14:07
 * @Version 1.0
 */
public class Demo1 {

    private Map<String, SearchWord> currentKeywords = new HashMap<>();

    public void refresh() {
        Map<String, SearchWord> newKeywords = new LinkedHashMap<>();
        // 从数据库中取出所有数据，放入到currentKeywords中
        List<SearchWord> toBeUpdatedSearchWords = getSearchWords();
        for (SearchWord searchWord : toBeUpdatedSearchWords) {
            newKeywords.put(searchWord.getKeyword(), searchWord);
        }
        currentKeywords = newKeywords;
    }

    private List<SearchWord> getSearchWords() {
        // TODO:从数据库中取出所有的数据
        return null;
    }
}
